<template>
	<view class="page">
		<u-navbar :title="title" @leftClick="$utils.back()" bgColor='rgba(0,0,0,0)' leftIconColor='#fff'
			:titleStyle='{color:"#fff"}'>
		</u-navbar>
		<swiper @change='change' class="swiper" :current='current'>
			<swiper-item :duration='0' v-for="(item,imageIndex) in imageList" :key="imageIndex" class="swiperItem">
				<image style="width: 100%;height: 100%;" mode='widthFix' :src="item.url"></image>
				<view class="title" v-if="item.title">
					{{item.title}}
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imageList: uni.getStorageSync('imageList'),
				index: 0,
				current: 0
			}
		},
		onLoad(op) {
			console.log(this.imageList,op)
			this.current = op.index
			this.index = ++op.index
		},
		computed: {
			title() {
				return `${this.index}/${this.imageList.length}`
			},
		},
		methods: {
			change(e) {
				this.index = ++e.detail.current
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		height: 100vh;
		padding-bottom: calc(constant(safe-area-inset-bottom) + 10rpx);
		/* 兼容 iOS 设备 */
		padding-bottom: calc(env(safe-area-inset-bottom) + 10rpx);
		box-sizing: border-box;
		background-color: #000;
	}

	.swiper {
		width: 100vw;
		height: 100vh;
	}

	.swiperItem {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
	}

	.title {
		color: #fff;
		position: absolute;
		bottom: calc(constant(safe-area-inset-bottom) + 10rpx);
		/* 兼容 iOS 设备 */
		bottom: calc(env(safe-area-inset-bottom) + 10rpx);
		left: 20rpx;
		width: calc(100vw - 40rpx);
		word-wrap: break-word;
	}
</style>